from fastapi import Depends, APIRouter
from pydantic import BaseModel

from api.acl.menu import Add_menu
from util.JWT import get_current_user

acl_menu = APIRouter()


# 添加用户
class AddMenuType(BaseModel):
    parent_id: int
    acl_name: str
    acl_type: int
    title: str


@acl_menu.post("/add_menu")
async def add_menu(data: AddMenuType, id: dict = Depends(get_current_user)):
    i = Add_menu(data)
    if i == 1:
        return {
            "code": 200,
            "status": "ok",
            "msg": "添加成功",
            "data": {}
        }
    else:
        return {
            "code": 204,
            "status": "no",
            "msg": "添加失败",
            "data": {}
        }
